package com.cqc.jdk8.Jutil.concurrent.locks.ReentrantLock.demo2;


import java.util.concurrent.locks.ReentrantLock;

public class Counter {
    private int count = 0;
    private ReentrantLock lock = new ReentrantLock();

    public void add() {
        lock.lock();
        try {
            count++;
            System.out.println(Thread.currentThread().getName() + ":" + count);
        } finally {
            lock.unlock();
        }
    }

    public int getCount() {
        return count;
    }
}
